<?php
	session_start();
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/StatisticService.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Context/BaseContext.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/ServiceResult/ServiceResult.php';
    $statisticService = new StatisticService();
   
	if(isset($_POST['dateFrom']) && isset($_POST['dateTo']) && isset($_POST['topNumber']))
	{
		$context = new BaseContext();
		$result = new ServiceResult();
		$dateFrom = $_POST['dateFrom'];
		$dateTo = $_POST['dateTo'];
		$topNumber = $_POST['topNumber'];
		$articleArr = $statisticService->getTopArticleByDate($context, $result, $dateFrom, $dateTo, $topNumber);
	}
?>

<table id="datatable">
	<thead>
		<tr>
			<th></th>
			<th>Article Code</th>
		</tr>
	</thead>
	<tbody>
	<?php 
		foreach ($articleArr as $article)
		{
	?>
		<tr>
			<th><?php echo $article['code'] ?></th>
			<td><?php echo $article['totalQuantity']; ?></td>
		</tr>
	<?php } ?>
	</tbody>
</table>

	